//获取assets静态资源
export const src = (url:string)=>{return new URL(`../assets/${url}`, import.meta.url).href;}

// 默认获取当前年月日时分秒,1获取当前年月日,2获取当前时分秒
export const currentTime = (num?:number) =>{
    const time = new Date(),
        thisYear = time.getFullYear(),
        thisMonth = time.getMonth() + 1,
        today = time.getDate(),
        hour = time.getHours(),
        minute = time.getMinutes(),
        second = time.getSeconds()

    const nyr = `${thisYear}-${thisMonth < 10 ? '0' + thisMonth : thisMonth}-${today < 10 ? '0' + today : today}`
    const sfm = `${hour < 10 ? '0' + hour : hour}:${minute < 10 ? '0' + minute : minute}:${second < 10 ? '0' + second : second}`

    if (num === 1) return nyr
    else if (num === 2) return sfm
    return `${nyr} ${sfm}`
}